package com.leyou.item.mapper;

import com.leyou.common.mapper.BaseMapper;
import com.leyou.item.entity.Sku;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.special.InsertListMapper;

/**
 * @package com.leyou.item.mapper
 * @description: Sku查询使用的mapper接口
 * @author: 许超越
 * @date 2019/6/29 15:20
 * @version: V1.0
 */
public interface SkuMapper extends BaseMapper<Sku>, InsertListMapper<Sku> {


    /**
     * 减库存
     * @param skuId
     * @param num
     * @return
     */
    @Update("UPDATE tb_sku SET stock = stock - #{num} WHERE id = #{skuId}")
    int minusStock(@Param("skuId") Long skuId, @Param("num") Integer num);


    /**
     * 增加库存
     * @param skuId
     * @param num
     * @return
     */
    @Update("UPDATE tb_sku SET stock = stock + #{num} WHERE id = #{skuId}")
    int plusStock(@Param("skuId") Long skuId, @Param("num") Integer num);
}
